package com.nwpu.server.search.controller;

import com.nwpu.server.common.response.R;
import com.nwpu.server.search.entity.NetworkRelationshipEntity;
import com.nwpu.server.search.service.NetworkRelationshipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: YuXingZh
 * @Date: Created in 16:25 2022-06-26
 * @Description:
 */
@RestController
@RequestMapping("search/networkrelationship")
public class NetworkRelationshipController {
    @Autowired
    private NetworkRelationshipService networkRelationshipService;

    @GetMapping("/getAll")
    public R testGetAll() {
        Iterable<NetworkRelationshipEntity> iterable = networkRelationshipService.getAll();
        iterable.forEach(e -> System.out.println(e.toString()));

        return R.ok().put("networkData", iterable);
    }

    @GetMapping("/getByName")
    public R GetByName(@RequestParam(value = "keyword", required = true) String keyword) {

        System.out.println(keyword);
        List<NetworkRelationshipEntity> list = networkRelationshipService.getByName(keyword);
        System.out.println(list);

        return R.ok().put("list", list);
    }
}
